package ext.tianma.part.AVLMaterial.validators;


import com.ptc.core.ui.validation.DefaultUIComponentValidator;
import com.ptc.core.ui.validation.UIValidationCriteria;
import com.ptc.core.ui.validation.UIValidationKey;
import com.ptc.core.ui.validation.UIValidationStatus;

import ext.tianma.bom.util.GenericUtil;
import wt.fc.Persistable;
import wt.fc.WTReference;
import wt.part.WTPart;
import wt.type.TypedUtility;

public class RangeChangeValidator extends DefaultUIComponentValidator {
	
	@Override
	public UIValidationStatus preValidateAction(UIValidationKey uivalidationkey,UIValidationCriteria uivalidationcriteria) {
		UIValidationStatus uivalidationstatus = UIValidationStatus.HIDDEN;
		try {
			WTReference wtreference = uivalidationcriteria.getContextObject();
            Persistable persistable = wtreference.getObject();
            
			
			if(persistable != null && persistable instanceof WTPart) {
			    WTPart wtpart = (WTPart) persistable;
			   
			    String partType = TypedUtility.getTypeIdentifier(wtpart).getTypename();
			    if (!"wt.part.WTPart|cn.tianma.AVLMaterial".equals(partType)){
			    	return uivalidationstatus;
				}else {
					return UIValidationStatus.ENABLED;
				}
			    
			}
					
			
		}catch (Exception e) {
			e.printStackTrace();
		}
		return uivalidationstatus;
	}

}
